<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */
namespace Plugin\Organization\Http\Request\Admin;

use Hyperf\Validation\Request\FormRequest;

/**
 * 用户权限申请验证数据类
 */
class RdOrganizeUserApplyRequest extends FormRequest
{
    /**
     * 场景配置
     */
    protected array $scenes = [
        'index' => [
            'user_id',
            'area',
            'area_ids',
            'apply_id',
            'status',
            'name',
            'apply_data',
            'created_at',
            'updated_at',
        ],
        'create' => [
            'user_id',
            'area',
            'area_ids',
            'apply_id',
            'status',
            'name',
            'apply_data',
            'remark'
        ],
        'update' => [
            'user_id',
            'area',
            'area_ids',
            'apply_id',
            'status',
            'name',
            'apply_data',
            'remark'
        ],
        'delete' => [ 'id', 'ids' ],
    ];

    public function authorize(): bool
    {
        return true;
    }


    /**
     * 新增数据验证规则
     * return array
     */
    public function rules(): array
    {
        return [
            'user_id' => 'integer|min:1',
            'area' => 'in:1,2,3',
            'area_ids' => 'array|min:1',
            'apply_id' => 'integer|min:1',
            'status' => 'in:1,2,3',
            'name' => 'required|string|max:255',
            'role' => 'in:1,2',
            'apply_data' => 'array',
            'remark' => 'string|max:255',
        ];
    }


    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'id' => '主键',
            'user_id' => '申请人',
            'area' => '申请范围1:项目,2:工区,3:站',
            'area_ids' => '申请范围id',
            'apply_id' => '审批人id',
            'status' => '状态1:待审批,2:通过,3:拒绝',
            'name' => '申请名称',
            'role' => '角色1:管理员,2:安全员',
            'apply_data' => '审批结果数据',
            'remark' => '备注',

        ];
    }

public function messages(): array
{
    return [
            'id.required' => '必填主键',
            'user_id.required' => '必填申请人',
            'area.required' => '必填申请范围1:项目,2:工区,3:站',
            'area_ids.required' => '必填申请范围id',
            'apply_id.required' => '必填审批人id',
            'status.required' => '必填状态1:待审批,2:通过,3:拒绝',
            'name.required' => '必填申请名称',
            'role.required' => '必填角色1:管理员,2:安全员',
            'apply_data.required' => '必填审批结果数据',
            'remark.required' => '必填备注',

    ];
}
}